home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
PlayerPRO 4.4.1
/
Filters Plugs
/
Backwards.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-16
|
2KB
|
79 lines
/* Backwards */
/* v 0.2 */
/* 1995 by Liane */
// Usage:
// Invert the selected part or all the waveform if
// there is no selection.
#include "MAD.h"
#include "PPPlug.h"
#if defined(powerc) || defined(__powerc)
enum {
PlayerPROPlug = kCStackBased
| RESULT_SIZE(SIZE_CODE( sizeof(OSErr)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof( Ptr*)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof( struct FileInstrData*)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof( long)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof( long)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof( PPInfoPlug*)))
};
ProcInfoType __procinfo = PlayerPROPlug;
#else
#include <A4Stuff.h>
#endif
OSErr main( Ptr *InstrumentPtr,
struct FileInstrData *theData,
long SelectionStart,
long SelectionEnd,
PPInfoPlug *thePPInfoPlug)
{
long i;
unsigned short temp1, temp2;
if (SelectionStart == SelectionEnd) {
SelectionStart = 0;
SelectionEnd = theData->insSize;
}
switch( theData->amplitude)
{
case 8:
{
Ptr orgPtr = *InstrumentPtr, destPtr = orgPtr;
orgPtr += SelectionStart;
destPtr += SelectionEnd - 1;
for( i = 0; i < (SelectionEnd - SelectionStart) / 2; i++) //just swap values
{
temp1 = *orgPtr;
temp2 = *destPtr;
*orgPtr++ = temp2;
*destPtr-- = temp1;
}
} break;
case 16:
{
unsigned short *orgPtr = (unsigned short*) *InstrumentPtr, *destPtr = orgPtr;
orgPtr += SelectionStart / 2;
destPtr += (SelectionEnd - 1) / 2;
for( i = 0; i < (SelectionEnd - SelectionStart) / 4; i++)
{
temp1 = *orgPtr;
temp2 = *destPtr;
*orgPtr++ = temp2;
*destPtr-- = temp1;
}
} break;
}
return noErr;
}